/*******************************************************************************
 * Copyright (c) 2011 Grupo de Sistemas Inteligentes (GSI) - DIT UPM
 *
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *******************************************************************************/
package es.upm.dit.gsi.eclipse.jadex.diagram.eclipseJadex.impl;

import es.upm.dit.gsi.eclipse.jadex.diagram.eclipseJadex.Agent;
import es.upm.dit.gsi.eclipse.jadex.diagram.eclipseJadex.Beliefs;
import es.upm.dit.gsi.eclipse.jadex.diagram.eclipseJadex.Capabilities;
import es.upm.dit.gsi.eclipse.jadex.diagram.eclipseJadex.Configurations;
import es.upm.dit.gsi.eclipse.jadex.diagram.eclipseJadex.EclipseJadexPackage;

import es.upm.dit.gsi.eclipse.jadex.diagram.eclipseJadex.Events;
import es.upm.dit.gsi.eclipse.jadex.diagram.eclipseJadex.Expressions;
import es.upm.dit.gsi.eclipse.jadex.diagram.eclipseJadex.Goals;
import es.upm.dit.gsi.eclipse.jadex.diagram.eclipseJadex.Imports;
import es.upm.dit.gsi.eclipse.jadex.diagram.eclipseJadex.Plans;
import es.upm.dit.gsi.eclipse.jadex.diagram.eclipseJadex.Properties;
import java.util.Collection;
import org.eclipse.emf.common.notify.Notification;

import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EClass;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.EObjectImpl;
import org.eclipse.emf.ecore.util.EObjectResolvingEList;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Agent</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link es.upm.dit.gsi.eclipse.jadex.diagram.eclipseJadex.impl.AgentImpl#getName <em>Name</em>}</li>
 *   <li>{@link es.upm.dit.gsi.eclipse.jadex.diagram.eclipseJadex.impl.AgentImpl#getBeliefs <em>Beliefs</em>}</li>
 *   <li>{@link es.upm.dit.gsi.eclipse.jadex.diagram.eclipseJadex.impl.AgentImpl#getCapabilities <em>Capabilities</em>}</li>
 *   <li>{@link es.upm.dit.gsi.eclipse.jadex.diagram.eclipseJadex.impl.AgentImpl#getConfiguratios <em>Configuratios</em>}</li>
 *   <li>{@link es.upm.dit.gsi.eclipse.jadex.diagram.eclipseJadex.impl.AgentImpl#getEvents <em>Events</em>}</li>
 *   <li>{@link es.upm.dit.gsi.eclipse.jadex.diagram.eclipseJadex.impl.AgentImpl#getExpressions <em>Expressions</em>}</li>
 *   <li>{@link es.upm.dit.gsi.eclipse.jadex.diagram.eclipseJadex.impl.AgentImpl#getGoals <em>Goals</em>}</li>
 *   <li>{@link es.upm.dit.gsi.eclipse.jadex.diagram.eclipseJadex.impl.AgentImpl#getImports <em>Imports</em>}</li>
 *   <li>{@link es.upm.dit.gsi.eclipse.jadex.diagram.eclipseJadex.impl.AgentImpl#getPlans <em>Plans</em>}</li>
 *   <li>{@link es.upm.dit.gsi.eclipse.jadex.diagram.eclipseJadex.impl.AgentImpl#getProperties <em>Properties</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class AgentImpl extends EObjectImpl implements Agent {
	/**
	 * The default value of the '{@link #getName() <em>Name</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getName()
	 * @generated
	 * @ordered
	 */
	protected static final String NAME_EDEFAULT = "";

	/**
	 * The cached value of the '{@link #getName() <em>Name</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getName()
	 * @generated
	 * @ordered
	 */
	protected String name = NAME_EDEFAULT;

	/**
	 * The cached value of the '{@link #getBeliefs() <em>Beliefs</em>}' reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getBeliefs()
	 * @generated
	 * @ordered
	 */
	protected EList<Beliefs> beliefs;

	/**
	 * The cached value of the '{@link #getCapabilities() <em>Capabilities</em>}' reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getCapabilities()
	 * @generated
	 * @ordered
	 */
	protected EList<Capabilities> capabilities;

	/**
	 * The cached value of the '{@link #getConfiguratios() <em>Configuratios</em>}' reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getConfiguratios()
	 * @generated
	 * @ordered
	 */
	protected EList<Configurations> configuratios;

	/**
	 * The cached value of the '{@link #getEvents() <em>Events</em>}' reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getEvents()
	 * @generated
	 * @ordered
	 */
	protected EList<Events> events;

	/**
	 * The cached value of the '{@link #getExpressions() <em>Expressions</em>}' reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getExpressions()
	 * @generated
	 * @ordered
	 */
	protected EList<Expressions> expressions;

	/**
	 * The cached value of the '{@link #getGoals() <em>Goals</em>}' reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getGoals()
	 * @generated
	 * @ordered
	 */
	protected EList<Goals> goals;

	/**
	 * The cached value of the '{@link #getImports() <em>Imports</em>}' reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getImports()
	 * @generated
	 * @ordered
	 */
	protected EList<Imports> imports;

	/**
	 * The cached value of the '{@link #getPlans() <em>Plans</em>}' reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getPlans()
	 * @generated
	 * @ordered
	 */
	protected EList<Plans> plans;

	/**
	 * The cached value of the '{@link #getProperties() <em>Properties</em>}' reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getProperties()
	 * @generated
	 * @ordered
	 */
	protected EList<Properties> properties;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected AgentImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return EclipseJadexPackage.Literals.AGENT;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String getName() {
		return name;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setName(String newName) {
		String oldName = name;
		name = newName;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, EclipseJadexPackage.AGENT__NAME, oldName, name));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<Beliefs> getBeliefs() {
		if (beliefs == null) {
			beliefs = new EObjectResolvingEList<Beliefs>(Beliefs.class, this, EclipseJadexPackage.AGENT__BELIEFS);
		}
		return beliefs;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<Capabilities> getCapabilities() {
		if (capabilities == null) {
			capabilities = new EObjectResolvingEList<Capabilities>(Capabilities.class, this, EclipseJadexPackage.AGENT__CAPABILITIES);
		}
		return capabilities;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<Configurations> getConfiguratios() {
		if (configuratios == null) {
			configuratios = new EObjectResolvingEList<Configurations>(Configurations.class, this, EclipseJadexPackage.AGENT__CONFIGURATIOS);
		}
		return configuratios;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<Events> getEvents() {
		if (events == null) {
			events = new EObjectResolvingEList<Events>(Events.class, this, EclipseJadexPackage.AGENT__EVENTS);
		}
		return events;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<Expressions> getExpressions() {
		if (expressions == null) {
			expressions = new EObjectResolvingEList<Expressions>(Expressions.class, this, EclipseJadexPackage.AGENT__EXPRESSIONS);
		}
		return expressions;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<Goals> getGoals() {
		if (goals == null) {
			goals = new EObjectResolvingEList<Goals>(Goals.class, this, EclipseJadexPackage.AGENT__GOALS);
		}
		return goals;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<Imports> getImports() {
		if (imports == null) {
			imports = new EObjectResolvingEList<Imports>(Imports.class, this, EclipseJadexPackage.AGENT__IMPORTS);
		}
		return imports;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<Plans> getPlans() {
		if (plans == null) {
			plans = new EObjectResolvingEList<Plans>(Plans.class, this, EclipseJadexPackage.AGENT__PLANS);
		}
		return plans;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<Properties> getProperties() {
		if (properties == null) {
			properties = new EObjectResolvingEList<Properties>(Properties.class, this, EclipseJadexPackage.AGENT__PROPERTIES);
		}
		return properties;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case EclipseJadexPackage.AGENT__NAME:
				return getName();
			case EclipseJadexPackage.AGENT__BELIEFS:
				return getBeliefs();
			case EclipseJadexPackage.AGENT__CAPABILITIES:
				return getCapabilities();
			case EclipseJadexPackage.AGENT__CONFIGURATIOS:
				return getConfiguratios();
			case EclipseJadexPackage.AGENT__EVENTS:
				return getEvents();
			case EclipseJadexPackage.AGENT__EXPRESSIONS:
				return getExpressions();
			case EclipseJadexPackage.AGENT__GOALS:
				return getGoals();
			case EclipseJadexPackage.AGENT__IMPORTS:
				return getImports();
			case EclipseJadexPackage.AGENT__PLANS:
				return getPlans();
			case EclipseJadexPackage.AGENT__PROPERTIES:
				return getProperties();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@SuppressWarnings("unchecked")
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case EclipseJadexPackage.AGENT__NAME:
				setName((String)newValue);
				return;
			case EclipseJadexPackage.AGENT__BELIEFS:
				getBeliefs().clear();
				getBeliefs().addAll((Collection<? extends Beliefs>)newValue);
				return;
			case EclipseJadexPackage.AGENT__CAPABILITIES:
				getCapabilities().clear();
				getCapabilities().addAll((Collection<? extends Capabilities>)newValue);
				return;
			case EclipseJadexPackage.AGENT__CONFIGURATIOS:
				getConfiguratios().clear();
				getConfiguratios().addAll((Collection<? extends Configurations>)newValue);
				return;
			case EclipseJadexPackage.AGENT__EVENTS:
				getEvents().clear();
				getEvents().addAll((Collection<? extends Events>)newValue);
				return;
			case EclipseJadexPackage.AGENT__EXPRESSIONS:
				getExpressions().clear();
				getExpressions().addAll((Collection<? extends Expressions>)newValue);
				return;
			case EclipseJadexPackage.AGENT__GOALS:
				getGoals().clear();
				getGoals().addAll((Collection<? extends Goals>)newValue);
				return;
			case EclipseJadexPackage.AGENT__IMPORTS:
				getImports().clear();
				getImports().addAll((Collection<? extends Imports>)newValue);
				return;
			case EclipseJadexPackage.AGENT__PLANS:
				getPlans().clear();
				getPlans().addAll((Collection<? extends Plans>)newValue);
				return;
			case EclipseJadexPackage.AGENT__PROPERTIES:
				getProperties().clear();
				getProperties().addAll((Collection<? extends Properties>)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case EclipseJadexPackage.AGENT__NAME:
				setName(NAME_EDEFAULT);
				return;
			case EclipseJadexPackage.AGENT__BELIEFS:
				getBeliefs().clear();
				return;
			case EclipseJadexPackage.AGENT__CAPABILITIES:
				getCapabilities().clear();
				return;
			case EclipseJadexPackage.AGENT__CONFIGURATIOS:
				getConfiguratios().clear();
				return;
			case EclipseJadexPackage.AGENT__EVENTS:
				getEvents().clear();
				return;
			case EclipseJadexPackage.AGENT__EXPRESSIONS:
				getExpressions().clear();
				return;
			case EclipseJadexPackage.AGENT__GOALS:
				getGoals().clear();
				return;
			case EclipseJadexPackage.AGENT__IMPORTS:
				getImports().clear();
				return;
			case EclipseJadexPackage.AGENT__PLANS:
				getPlans().clear();
				return;
			case EclipseJadexPackage.AGENT__PROPERTIES:
				getProperties().clear();
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case EclipseJadexPackage.AGENT__NAME:
				return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name);
			case EclipseJadexPackage.AGENT__BELIEFS:
				return beliefs != null && !beliefs.isEmpty();
			case EclipseJadexPackage.AGENT__CAPABILITIES:
				return capabilities != null && !capabilities.isEmpty();
			case EclipseJadexPackage.AGENT__CONFIGURATIOS:
				return configuratios != null && !configuratios.isEmpty();
			case EclipseJadexPackage.AGENT__EVENTS:
				return events != null && !events.isEmpty();
			case EclipseJadexPackage.AGENT__EXPRESSIONS:
				return expressions != null && !expressions.isEmpty();
			case EclipseJadexPackage.AGENT__GOALS:
				return goals != null && !goals.isEmpty();
			case EclipseJadexPackage.AGENT__IMPORTS:
				return imports != null && !imports.isEmpty();
			case EclipseJadexPackage.AGENT__PLANS:
				return plans != null && !plans.isEmpty();
			case EclipseJadexPackage.AGENT__PROPERTIES:
				return properties != null && !properties.isEmpty();
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public String toString() {
		if (eIsProxy()) return super.toString();

		StringBuffer result = new StringBuffer(super.toString());
		result.append(" (Name: ");
		result.append(name);
		result.append(')');
		return result.toString();
	}

} //AgentImpl
